Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Generic
Imports Cdm.DataCore.Custom
Imports Cdm.DataCore.LookupTables

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AutoComplete
    Inherits System.Web.Services.WebService


    <WebMethod(EnableSession:=True)> _
Public Function GetParticipants(ByVal prefixText As String, ByVal count As Integer) As String()

        Dim userId As Integer = UserAuthorization.CurrentUser.UserId

        If userId = 0 Then Return Nothing
        Dim participantList As List(Of ParticipantDisplay) = ParticipantDisplay.ListByNameSearch(userId, prefixText)
        If participantList Is Nothing Then Return Nothing
        If participantList.Count = 0 Then Return Nothing
        Dim upperBound As Integer = count - 1
        If participantList.Count < count Then upperBound = participantList.Count - 1

        Dim returnString(upperBound) As String
        For i As Integer = 0 To upperBound
            returnString(i) = participantList(i).DisplayLastNameFirstWithId
        Next
        Return returnString
    End Function

    <WebMethod()> _
    Public Function GetItemCodes(ByVal prefixText As String, ByVal count As Integer) As String()



        Dim itemCodeList As List(Of LuItemCode) = LuItemCode.ListBySearch(prefixText)
        If itemCodeList Is Nothing Then Return Nothing
        If itemCodeList.Count = 0 Then Return Nothing
        Dim upperBound As Integer = count - 1
        If itemCodeList.Count < count Then upperBound = itemCodeList.Count - 1

        Dim returnString(upperBound) As String
        For i As Integer = 0 To upperBound
            returnString(i) = itemCodeList(i).LookupIdAndDescription
        Next
        Return returnString

    End Function

    <WebMethod()> _
  Public Function GetServiceCodes(ByVal prefixText As String, ByVal count As Integer) As String()



        Dim serviceCodeList As List(Of LuServiceCode) = LuServiceCode.ListBySearch(prefixText)
        If serviceCodeList Is Nothing Then Return Nothing
        If serviceCodeList.Count = 0 Then Return Nothing
        Dim upperBound As Integer = count - 1
        If serviceCodeList.Count < count Then upperBound = serviceCodeList.Count - 1

        Dim returnString(upperBound) As String
        For i As Integer = 0 To upperBound
            returnString(i) = serviceCodeList(i).LookupIdAndDescription
        Next
        Return returnString

    End Function

End Class
